/**
 * @author tianchao
 */
import request from '@/utils/request'

/**
 * 根据搜索条件查询组织树
 * @param {*} query
 */
export function roleListByName(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getOrgTreeByName',
    method: 'post',
    data
  })
}

/**
 * 获取角色对应用户列表
 * @param {*} query
 */
export function userList(query) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDataAuthority/queryPage',
    method: 'post',
    data: query
  })
}

/**
 * 删除角色权限用户
 * @param {*} ids
 */
export function deleteUser(ids) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDataAuthority/delete',
    method: 'post',
    data: {
      ids
    }
  })
}
/**
 * 为角色添加用户
 * @param {*} query
 */
export function insertRoleUser(query) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDataAuthority/insert',
    method: 'post',
    data: query
  })
}
/**
 * 字典
 */
export function getDictByCode(dictCode) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDictionary/getDictByCode',
    method: 'POST',
    data: {
      dictCode
    }
  })
}
/**
 * 新增一级企业信息
 * @param {*} data
 */
export function createFirst(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/insert',
    method: 'post',
    data
  })
}
/**
 * 新增下级企业信息
 * @param {*} data
 */
export function insert(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/insert',
    method: 'post',
    data
  })
}
/**
 * 编辑下级企业信息
 * @param {*} data
 */
export function update(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/update',
    method: 'post',
    data
  })
}
/**
 * 编辑下级企业信息
 * @param {*} id
 */
export function get(id) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/get',
    method: 'get',
    params: {
      id
    }
  })
}
/**
 * 删除企业信息
 * @param {*} ids
 */
export function del(ids) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/delete',
    method: 'get',
    params: {
      ids
    }
  })
}
/**
 * 获取企业权限树(异步)也可以用于下拉选择以及企业
 */
export function getComTreeSync(parentId) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getLeaf',
    method: 'get',
    params: {
      parentId
    }
  })
}
/**
 * 根据ids查询企业列表（用于选择发布企业数据回显）
 */
export function getSelectCompany(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/queryEnterprise',
    method: 'post',
    data
  })
}
/**
 * 查询角色列表
 * @param {*} data
 */
export function queryUserRole(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysUserLogin/userSelectQueryPage',
    method: 'post',
    data
  })
}
/**
 * 异步企业部门树
 */
export function getComAndOrgTree(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/queryOrgAndDep',
    method: 'post',
    data
  })
}
